package cn.iocoder.yudao.module.energy.dal.mysql.device;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.energy.controller.admin.device.vo.EnergyDevicePageReqVO;
import cn.iocoder.yudao.module.energy.dal.dataobject.device.EnergyDeviceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 能耗设备 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EnergyDeviceMapper extends BaseMapperX<EnergyDeviceDO> {

    default PageResult<EnergyDeviceDO> selectPage(EnergyDevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnergyDeviceDO>()
                .likeIfPresent(EnergyDeviceDO::getDeviceId, reqVO.getDeviceId())
                .likeIfPresent(EnergyDeviceDO::getDeviceName, reqVO.getDeviceName())
                .likeIfPresent(EnergyDeviceDO::getModel, reqVO.getModel())
                .likeIfPresent(EnergyDeviceDO::getLocation, reqVO.getLocation())
                .eqIfPresent(EnergyDeviceDO::getEnergyType, reqVO.getEnergyType())
                .eqIfPresent(EnergyDeviceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(EnergyDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EnergyDeviceDO::getId));
    }

    default List<EnergyDeviceDO> selectList() {
        return selectList(new LambdaQueryWrapperX<EnergyDeviceDO>()
                .orderByAsc(EnergyDeviceDO::getDeviceName));
    }

    default List<EnergyDeviceDO> selectList(EnergyDevicePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EnergyDeviceDO>()
                .likeIfPresent(EnergyDeviceDO::getDeviceId, reqVO.getDeviceId())
                .likeIfPresent(EnergyDeviceDO::getDeviceName, reqVO.getDeviceName())
                .likeIfPresent(EnergyDeviceDO::getModel, reqVO.getModel())
                .likeIfPresent(EnergyDeviceDO::getLocation, reqVO.getLocation())
                .eqIfPresent(EnergyDeviceDO::getEnergyType, reqVO.getEnergyType())
                .eqIfPresent(EnergyDeviceDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(EnergyDeviceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EnergyDeviceDO::getId));
    }
} 